<?php
// +----------------------------------------------------------------------
// | PHP [ JUST YOU ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2017 http://www.jyphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: FlyingPig <flyingpigfp@163.com>
// +----------------------------------------------------------------------

namespace App\Http\Controllers;


use App\Exceptions\ApiException;
use Illuminate\Support\Facades\DB;

class Feedback extends Base
{

    public function create()
    {
        $count = DB::table('t_feedback_info')->where('uid',$this->uid)->where('create_time','>',date('Y-m-d'))->count('id');
        if ($count >= 2) {
            throw new ApiException('一天只能反馈2条信息');
        }
        if (mb_strlen($this->param['content'] > 100)) {
            throw new ApiException('内容最多100字符');
        }
        DB::table('t_feedback_info')->insert([
            'uid' => $this->uid,
            'title' => $this->param['title'],
            'content' => $this->param['content'],
        ]);
        return $this->returnData();
    }


}